import time
from prometheus_client import Gauge,start_http_server

#custom_test_metric{ labelkey1="labelvalue1",labelkey2="labelvalue2" } 123.0
#指标名：custom_test_metric   标签：labelkey1，labelkey2
g = Gauge('custom_test_metric', 'Description of gauge', ['labelkey1','labelkey2'])

if __name__ == '__main__':
    start_http_server(8006)  # 8006端口启动
    while True:
        #将上一次的值去除
        g.clear()
        #设置标签以及监控数据的值
        g.labels(labelkey1="labelvalue1",labelkey2="labelvalue2").set("123")
        time.sleep(10)
